package com.itmeima.dao;

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.jdbc.core.JdbcTemplate;

public class SingletonTemplate {
    private static JdbcTemplate jdbcTemplate;
    public static JdbcTemplate getjdbcTemplate(){
        if (jdbcTemplate != null){
            return jdbcTemplate;
        }

        DruidDataSource druidDataSource = new DruidDataSource();
        druidDataSource.setDriverClassName("com.mysql.jdbc.Driver");
        druidDataSource.setUsername("root");
        druidDataSource.setPassword("root");
        druidDataSource.setUrl("jdbc:mysql://localhost:3306/test");
        jdbcTemplate = new JdbcTemplate();
        jdbcTemplate.setDataSource(druidDataSource);
        return jdbcTemplate;

    }
}
